home *** CD-ROM | disk | FTP | other *** search
- New items added 02/14/88 to 02/20/88:
-
- Part 1 - CALL (Asm) - Don't have label at END statement
- * next to a QB 4 entry indicates that the problem has been
- fixed with the QB 4.00a that is included in BASCOM 6.
- DIM QB 4
- OPEN COM QB 4
- Part 2 - Color patches don't affect Hercules
- -------------------------------------------------------------------------
-
- This file contains information about bugs, quirks, and general points
- of interest to programmers working with compiled BASIC. It is divided
- into three parts:
-
- Part 1 - Description of bugs, quirks and errors
- Part 2 - General points of interest
- Part 3 - Sample programs
-
- If you want to find one of the above quickly, use your text editor to
- search for the text shown above. i.e., Search for "Part 1 -".
-
- This file is maintained by Mark Novisoff of MicroHelp, Inc. Much of the
- information was contributed by members of MicroHelp's BASIC Users Group.
- If you have additional information that should be added, please send it
- to:
- Mark Novisoff
- MicroHelp, Inc.
- 2220 Carlyle Drive
- Marietta GA 30062
- (404) 973-9272
- Compuserve ID 73047,3706 in MSSYS (Microsoft Systems Forum)
-
- Part 1 - Description of bugs, quirks and errors
-
- Note: * Next to a QB 4 entry indicates that the problem has been
- fixed with the QB 4.00a that is included in BASCOM 6.
-
- Command/Error Compilers Description
- -------------- --------------- --------------------------------------------
- $INCLUDE QB 4 If you have a DEFINT statement in an include
- file and you wish to use it within subprograms/
- functions in a module, you must $INCLUDE it
- within each sub/function structure. If you
- simply include it in the mainline code, the
- DEFINT statement is not recognized. However,
- if you have a statement DEFINT in your mainline
- code (as opposed to $INCLUDE), it will work ok.
- CALL (asm) QB 4 Effective with QB 4, assembly
- language subroutines must preserve
- the SI and DI registers and make
- sure the direction flag is cleared
- before returning to BASIC.
- In addition, you must not have a label name
- after the END statement in your assembler code.
- CALL INIT QB 2-3 Do not name a precompiled subprogram "INIT".
- If you do, the compiler will go into never-
- never land when your user library is loaded.
- CALL vs GOSUB All If you have many calls to the same
- asm routine or subprogram, you'll
- use less memory if you set
- variables and GOSUB to a routine
- that performs the CALL instead of
- having the CALL "in line". CALL is
- much faster using variables than
- using "literals".
- CALLS QB 4* When CALLS (note the "S") is used and you
- compile with "/D" (debug), the segment of
- of a string element descriptor does not get
- passed on the stack. In other words, if you
- have an assembly language subroutine that
- uses CALLS, you should not compile with "/d".
- CHAIN QB 4 Unreliable when using DOS 2.x.
- CIRCLE QB 4 The start and end angles must be
- LESS than 2*pi. Previously they could
- be less than or equal to.
- CLEAR,,Size QB 3,4 If you receive an out of stack
- space message. The stack size is
- not reset between CHAIN'ing but if
- you CHAIN back to your original
- program, be sure to skip the CLEAR
- instruction.
- COMMON and QB 2-4 All statements that use COMMON or variations
- COMMON SHARED thereon with CHAIN must use parameter lists
- that match exactly. Best done with $INCLUDE.
- COMMON with TYPE
- QB 4 The TYPE statement must appear before
- the COMMON statement and must appear in
- all programs that use it. The COMMON
- statement must contain "AS". See sample
- program #1 at the end of this file.
- Compile to EXE QB 4 QB issues an unusual LINK command in the
- form of:
- LINK Prog+YourLib.Lib;
- This causes LINK to bring the entire
- library into your program! The solution is
- to exit QB, and run BC and LINK yourself.
- CONST QB 4 Must be included in all program modules
- that use the constant. Place in the file
- at the top, rather than inside SUB's.
- DATA QB 4 When a DATA statement is encountered inside
- a SUB...END SUB structure, QB moves it
- into the "mainline" portion of the code when
- you are in the environment.
- DEFINT QB 4 See $INCLUDE.
- DEF FN All Functions are local to the module
- in which the DEF FN appears. Use
- QB 4's FUNCTION..END FUNCTION for
- global functions.
- DIM QB 3 See sample program #4. QB3 apparently has
- a limit of 123 dynamic arrays.
- DIM QB 4 In order to take advantage of the /AH switch
- with TYPE..END TYPE records, the record
- length must be a power of 2 (4,8,16,32, etc.)
- DIM QB 4 Static numeric arrays are stored on the
- "heap" when you are inside the QB 4
- environment. BC programs store them in the
- default DS.
- DIM (TYPE) QB 4 See sample program #1 for dimensioning
- arrays of TYPE'd variables.
- Division All Using integer division "\" when an
- integer result is desired is much
- faster than normal division "/".
- DRAW QB 2-4 Does not respect the boundaries designated
- by WINDOW.
- ERR QB 4 Inside the QB 4 environment. If you watch
- a variable, ERR does not get set properly
- when an error occurs. See sample program #5.
- FIELD QB 4 We've had a report that if you use array
- elements for FIELD'ing a Btrieve file, and
- you don't DIM the string array (i.e., you
- default to 10 elements) that you can get
- string space corrupt errors. The solution
- is always to DIM the arrays.
- FILES QB 3 There is a bug in the QB3-8087 compiler that
- causes FILES not to work correctly.
- FOR/NEXT QB 4* If you use a long integer as your loop
- counter, with a negative STEP, your loop
- will not execute.
- FOR/NEXT QB 4 If you use an integer for a loop counter,
- and the top of the loop is 32767 (when
- STEP is positive) or the bottom of the
- loop is -32768 (when STEP is negative),
- you'll get an overflow when inside the QB
- environment or when compiled with BC using
- "/d". With BC,if you don't use "/d", the loop
- does not stop at the top/bottom - it wraps
- around and executes your loop indefinitely.
- FRE(-1) QB 4 If a Quick Library is loaded, this value
- may return incorrectly. QB 4 seems to
- forget that the library is loaded and
- thinks that the space is available. But,
- QB 4 won't let you use the space for
- dynamic arrays.
- FRE("") QB 4* Using BRUN gives approximately 4K more
- than BCOM. Here is a table showing the
- difference between compilers for a one
- line program PRINT FRE(""):
-
- BC BC6
- BRUN 57280 59912
- BCOM 61560 61640
- FUNCTION QB 4 Provides global functions for all
- modules in a program. All that is
- needed is a DECLARE statement in
- any module that needs to use the
- function. In addition, this type
- of function can be recursive. See DEF FN.
- FUNCTION QB 4 Cannot be used in $INCLUDE files.
- HEX$ QB 4 Be careful when using with non-integer
- values. For example, the output from
- the two lines shown is "FFFF8002".
- E&=&H8002
- PRINT HEX$(E&)
- IF..THEN..ELSE QB 3 More than two nestings for ELSE on a single
- line will not compiler properly.
- LIB.EXE n/a LIB cannot recognize the name of a library
- if you precede the library name with a path
- that contains a hyphen "-". For example, if
- you enter the following, LIB will fail:
- LIB Test-Dir\MyLib <Enter>
- LINE INPUT QB 4* Don't attempt to LINE INPUT directly to a typed
- variable (using TYPE...END TYPE) that has
- a period in the name. Rather, LINE INPUT to a
- temporary variable and then assign it to
- the TYPE'd variable.
- LINK All Use the /EXEPACK switch to condense the
- file. Can be used on any program except
- programs that are CHAIN'ed to using
- all compilers except QB 4. All QB 4
- programs can use this switch. Syntax:
- LINK /EXE Progname (etc.)
- LINK QB 4 When building a Quick Library, be sure
- to specify BQLB40 in the library field. Example:
- LINK /QU ObjMods,Lib,,BQLB40;
- LOAD QB 4 If you receive an "out of memory"
- error, try breaking your program
- into logical pieces (using
- subprograms). Then use COMMON
- SHARED for all variables that you
- need in the entire program. The
- exact same COMMON SHARED
- declaration must appear in all the
- modules in the program that need
- access to the variables.
- LOAD QB 4 If you download a QB 4 program in "fast load"
- format, many modem transfer protocols
- pad the file out using a number of
- CHR$(0)'s. This will cause QB 4 to
- crash when you attempt to load the program.
- Use DEBUG to view the file, then write
- the program to disk after changing the
- CX register to shorten the length of the
- file so that the trailing CHR$(0)'s are
- not included. The other solution is to
- download this type of file using an ARC
- program that restores the original length
- of the file.
- ON ERROR QB 4* If the first ON ERROR statement in your
- program is "ON ERROR GOTO 0", two problems
- can occur:
- 1. If an error occurs in your program,
- your system will crash.
- 2. You may get a "Program memory overflow"
- error from BC 4.
- The solution is that the first ON ERROR GOTO
- should not be to line "0".
- ON ERROR QB 4 See "RESUME" for QB 4.
- ON ERROR QB 2-4 Error handler routines must be located
- outside SUB...END SUB structures. You
- can RESUME to a line number/label that
- is outside SUB...END SUB structures
- (using /E) or to code inside the sub
- using plain RESUME or RESUME
- NEXT (/X). Much better is to $INCLUDE
- subroutines that perform error trapping
- instead of having them in subprograms.
- This allows the use of RESUME line number/
- label and avoids the /X.
- OPEN COM QB 4* If you open the COM port within
- the environment, then compile to an EXE
- from within the environment, you get a
- "far heap corrupt" error.
- OPEN COM QB 4* If you open a COM port, close the port, then
- do a SHELL, you cannot reopen the same port.
- The compiler sets the COM port address
- (at hex 40:0 through 40:7, depending on the
- COM port number) to 0 and cannot find the
- port. The solution is to leave the port
- open during the SHELL.
- OPEN All With Novell NetWare, using OPEN on a file that
- does not exist does not always create the file.
- Novell has acknowledged the problem but no
- solution is available as of 12/19/87.
- Overflow All BASIC uses integer types for all
- calculations and processes the
- right side of the equal sign
- before the left side. To force
- BASIC to use a different numeric
- type, place a type identifier on
- the right of the equal sign.
- Example: A=Peek(2)+256!*Peek(3)
- PRINT # QB 4 In order to print a blank line using QB 4,
- use the syntax:
- PRINT #,
- Note the absence of the null string after
- the comma. We've had an unconfirmed report
- that if the print buffer is filled, using
- the null string causes characters to be
- dropped.
- PRINT USING QB 4 With previous compilers, you could place TAB
- statements, variable names, or most anything
- else between PRINT and USING. With QB 4,
- nothing should come between PRINT and USING.
- REDIM QB 3 If you have a subprogram that REDIM's arrays,
- and you get a "string space corrupt" message
- after calling the subprogram several times,
- try using ERASE on the array before you do
- the REDIM.
- RESUME All If you always use RESUME
- <linenumber> or RESUME <label> you
- can use the "/e" switch instead of
- "/x". Makes programs smaller!
- This is not practical for
- subprograms, so error trapping is
- better handled in mainline code.
- See ON ERROR.
- RESUME QB 4 If you compile to an EXE from
- inside the environment, a "/X" is
- generated by QB even though it's
- not needed. Be sure to recompile
- with "/E" outside of the
- environment if your program
- doesn't need "/X".
- RUN QB 4* See sample program #3. If you use RUN in a
- program that has soft key definitions, the
- system will crash if the program was compiled
- with BC. It will work OK in the environment.
- SADD QB 4 When using SADD-188 for Btrieve,
- be sure to make this calculation
- EACH TIME you are going to CALL
- Btrieve. This is because QB 4 can
- move the FIELD'ed strings around
- in memory.
- SAVE QB 4 If you edit a new program and save it,
- QB defaults to "fast load" format. The
- file cannot be handled by a text editor.
- Fix by using "save as".
- SELECT CASE QB 3 Much less forgiving than QB 4. For example,
- when using a string, you can't say:
- CASE CHR$(3)
- However, you can embed the literal character
- with an ASCII value of 3 in quotes!
- SELECT CASE QB 4 You cannot have a line number or label
- between the SELECT CASE and the first CASE.
- SELECT CASE QB 4* Doesn't allow periods in variable names that
- are "plain" variables. If using a TYPE'd
- record element (which does indeed use periods),
- QB 4 will accept that with no problem.
- SIGNAL QB 4* BC 6 - Similar to event trapping, but for OS/2.
- SLEEP QB 4* BC 6 - Suspends the program, waiting for a
- user-defined event.
- SOUND QB 3/87 Generates error 6 in all forms when the
- emulator is used on non-87 machines.
- STATIC QB 4 When used with a subprogram, makes
- the subprogram faster, since local
- variables are not initialized on
- each call.
- String Space QB 4 Drops you out to DOS without saving
- Corrupt your program. The solution is to save
- often!
- STRING$ All A$=String$(5,65) takes less code than
- A$=String$(5,"A") and both are smaller
- than A$="AAAAA".
- SUB...END SUB QB 4 Cannot be used in $INCLUDE files. Cannot
- have the same name as a variable (regardless
- of the variable type).
- TYPE..END TYPE QB 4 There has been an unverified problem reported
- in QB when the record length is an odd number.
- A "FAR HEAP CORRUPT" error is generated.
- The problem reportedly occurs when the record
- length is an odd number of bytes. It does not
- seem to appear in BC, only QB. If you have
- an unusual, otherwise unexplained problem,
- try changing the record length to an even number.
- TYPE..END TYPE QB 4 See "DIM" for QB 4.
- TYPE..END TYPE
- (with COMMON) QB 4 See COMMON (with TYPE) and sample program #1.
- UBOUND QB 2-3 If you ERASE an array, UBOUND will return the
- upper bound of the array BEFORE it was erased.
- This works OK in QB 4.
- VAL QB 4 Generates an error (rather than value of 0)
- when "%" is the first character in the string.
- WINDOW QB 2-4 Does not affect DRAW statements.
- ----------------------------------------------------------------------------
- Part 2 - General points of interest
- ----------------------------------------------------------------------------
- Long integers with QB 4
-
- When you have a long integer array with two dimensions, BC may not handle
- the zeroth elements correctly on machines without a math coprocessor
- unless you use the "/d" switch. QB handles the situation OK because "debug"
- is always on when working in the environment.
-
- Secondly, if you dimension the same two-dimensional array using a variable
- name instead of a numeric constant, BC may not handle your array at all! The
- fix is to use only constant numbers in dimensioning the array. Another fix
- that DOES work with dynamic arrays, is to use the /R switch when compiling.
- ----------------------------------------------------------------------------
- More on long integers
-
- If you pass a long integer array to a subprogram, QB will work OK, but
- BC does not. See Sample Program #2.
- ----------------------------------------------------------------------------
- LIB environment variable
-
- If you set the LIB environment variable, you will find that QB, BC, BUILDLIB
- and LINK will all search the specified path whenever a User Lib, Quick Lib or
- LINK lib is needed. The syntax is similar to the DOS Path syntax:
-
- SET LIB=C:\Libs;C:\DOS;C:\QB
- ----------------------------------------------------------------------------
- Undocumented switches in QuickBASIC 3
-
- QB ProgramName/F compiles the specified program to an EXE file without
- starting up the QB editor.
-
- QB ProgramName/Z tells QB to load and execute ProgramName and exit to DOS
- when the program ends.
- ----------------------------------------------------------------------------
- Response files
-
- BUILDLIB and LINK both accept input from response files. This is exactly the
- same as redirection of input, but the programs will continue running when
- the end of the file is reached prematurely. Example:
-
- Response file contains:
- Prog1+Prog2+Prog3+
- Prog4+Prog5+Prog6 Rem Don't include ANY additional blank lines
-
- Buildlib batch file contains:
- Buildlib @Response.Fil,MyLib.Exe;
-
- Buildlib will take its input from the response file because the "@" sign
- tells it to!
- ----------------------------------------------------------------------------
- BUILDLIB and "too many segments" error
-
- Where "nnnn" is a number from 1 to 1024, use:
-
- BUILDLIB /SEG:nnnn
-
- That increases (or decreases) the number of allowable segments. Default=255.
- ----------------------------------------------------------------------------
- Patching QB 4 menu and help colors.
-
- This color table in this file was uploaded by Dave Engfer to the
- MicroHelp Basic Users Group BBS. Note that if you are running QB on a
- Hercules board, these patches won't have any effect.
-
- If you don't like the colors that QB 4.0 uses, you can patch it to show
- the colors you want. In order to effect your patches, do the following:
-
- Make a backup copy of QB.EXE.
- REN QB.EXE QB <Enter>
- DEBUG QB <Enter>
- R <Enter>
-
- At this point, debug will show you the current register settings and
- the current instruction. Something like this:
-
- -r
- AX=0000 BX=0003 CX=82A0 etc.
- DS=xxxx ES=xxxx SS=xxxx etc.
- xxxx:0100 RD DEC BP
-
- The "xxxx" is the current code segment. On my machine, the value is 2A28.
- The color table that QB uses is located near the end of the QB program,
- specifically 3 full segments higher than "xxxx". That means you will
- need to add 3000 hex to the number of the segment shown. In my case,
- I would patch segment 5A28. Note that adding 3 to the first of the four
- hex numbers does the trick.
-
- Now, with the higher segment address in mind, display the existing color
- table. Remember, the segment on your machine is most likely different
- from mine, but the offset "5B6F" should be the same. On my system:
-
- d 5A28:5B6F <Enter>
-
- gives the following table (on my system, "xxxx" is 5A28):
-
- xxxx:5B60 34
- xxxx:5B70 30 4F 34 30 38 4F 47 34-38 70 71 74 07 47 0A 30
- xxxx:5B80 3F 17 4A 00 07 70 70 0F-7F 70 78 0F 07 7F 70 70 etc.
-
- Below you'll find a table of the colors and what Dave thinks they represent.
- Note that some are marked "unknown". Dave suspects they may be related to
- rodents.
-
- You can change your copy of QB to display the various colors by changing
- the values in the table. The formula for determining color is the same as
- in Mach 2: Attribute=Background*16+Foreground.
-
- As an example, suppose you want to change the "top line highlight" to
- red on green (XMAS is only a month away!). The color attribute we want
- (in HEX for debug) is 2*16+4 or 36 decimal or 24 HEX.
-
- So, to patch that color:
-
- -e xxxx:5B71 24 <Enter>
- -w <Enter>
- -q <Enter>
- REN QB QB.EXE
-
- Now, when you hold the Alt key (without pressing anything else), "File"
- appears in red on green.
-
- Original Color Addr Byte Effect
- ---------------------------------------------------------------------
- Red on Cyan 5B6F 34 The outline for the pulldown boxes
- Black on Cyan 5B70 30 The Color for the top line
- Bright White on Red 5B71 4F Top line Highlight (e.i. press 'Atl'
- and the option will highlight)
- Red on Cyan 5B72 34 Top line first letter highlight
- Black on Cyan 5B73 30 *Pulldown box text and background - 1
- Bright Black on Cyan 5B74 38 *Pulldown box text and background - 2
- Bright White on Red 5B75 4F *Pulldown box highlight line - 1
- White on Red 5B76 47 *Pulldown box highlight line - 2
- Red on Cyan 5B77 34 *Pulldown box first letters - 1
- Bright Black on Cyan 5B78 38 *Pulldown box first letters - 2
- Black on White 5B79 70 Frame around the Help box- Shft F1
- Blue on white 5B7A 71 Help box selection area- Shft F1
- Red on White 5B7B 74 Help box first letter highlight- F1
- White on Black 5B7C 07 Normal text (Default)
- White on Red 5B7D 47 Breakpoint line (Default)
- Bright Green on Black 5B7E 0A Current line (Default)
- Black on Cyan 5B7F 30 Bottom line prompt text
- Bright White on Cyan 5B80 3F Microsoft Copyright Notice
-
- Notes-
- * - Microsoft uses two different color bytes for the pulldown boxes.
- 1 - This byte seems to be used for options with a highlight letter.
- 2 - This byte seens to be used for options without a highlight letter.
- ----------------------------------------------------------------------------
- DTR patch (QB4 BCOM)
-
- See instructions on patching colors (above) for patching BCOM40.LIB so that
- standalone programs do not drop DTR during a SHELL. A side effect is that
- after closing the COM file, DTR remains up.
-
- ** Note **
- The success or failure of this patch has not been confirmed. At this time,
- it has simply been reported by a user. If anyone has any feedback, I'd
- sure appreciate it.
-
- Patch the 1st segment above the default DS (add &H1000 to default). All
- values are in HEX.
-
- Address Old Value New Value
- ------- --------- ---------
- 2A42 32 B0
- 2A43 C0 01
- 2D0C 32 B0
- 2D0D C0 B1
-
- ----------------------------------------------------------------------------
- Entering unusual ASCII values.
-
- If you're not familiar with WordStar, you may not know that you can enter
- unusual characters into the QB4 editor by doing the following:
-
- Hold the Ctrl key and press "P" once (nothing will happen).
- Release the Ctrl key.
- Press and hold the Alt key.
- Using the keypad number keys (not the keys on the top of the keyboard),
- enter the ASCII value for the key you want. For example, the 'Esc' key
- is ASCII 27, so press the "2", then the "7".
- Release the Alt key, and your special character will appear!
- ----------------------------------------------------------------------------
- Part 3 - Sample programs
- ----------------------------------------------------------------------------
- Sample program #1. How to use COMMON with TYPE'd variables.
-
- ' Prog1.bas
-
- TYPE Namerec
- LastName AS STRING * 20
- FirstName AS STRING *15
- END TYPE
- COMMON Filename() AS Namerec
- DIM Filename(5) AS Namerec
- Filename(1).LastName="Novisoff"
- Filename(1).FirstName="Mark"
- CHAIN "Prog2"
-
- ' Prog2.bas
-
- TYPE Namerec
- LastName AS STRING * 20
- FirstName AS STRING * 15
- END TYPE
- COMMON Filename() AS Namerec
- PRINT Filename(1).LastName, Filename(1).FirstName
-
- ----------------------------------------------------------------------------
- Sample program #2. Demonstrates problem with long integers in subprograms.
-
- DECLARE SUB TestLong (LongArray&())
- 'Demonstration to show difference between return values of long integers
-
- 'Returns desired value if compiled in the environment, but not if compiled
- 'by BC.
-
- 'This fault only appears if the code is in a subprogram and compiled with BC
- REM $Dynamic
- DIM LongArray&(10)
- DIM MainArray%(10)
-
- CLS
- LongArray&(1) = 100
- MainArray%(1) = 10
-
- FOR x% = 1 TO 2
- LongArray&(1) = MainArray%(1) + LongArray&(1)
- ' Note: if you change the above into the following two lines, this part
- ' of the program will run correctly.
- 'Temp& = MainArray%(1)
- 'LongArray&(1) = Temp& + LongArray&(1)
- NEXT
-
- PRINT "TestLong should = 120"
- PRINT "Long Array from MAIN = "; LongArray&(1)
- PRINT : PRINT "Same code in a subprogram"
- PRINT
-
- CALL TestLong(LongArray&())
-
- PRINT "TestLong should return 120"
- PRINT "Long Array from TestLong sub = "; LongArray&(1)
-
- SUB TestLong (LongArray&())
- DIM IntArray%(10)
-
- LongArray&(1) = 100
- IntArray%(1) = 10
-
- FOR x% = 1 TO 2
- LongArray&(1) = IntArray%(1) + LongArray&(1)
- ' Note: if you change the above into the following two lines, this part
- ' of the program will run correctly.
- 'Temp& = IntArray%(1)
- 'LongArray&(1) = Temp& + LongArray&(1)
- NEXT
- END SUB
-
- ----------------------------------------------------------------------------
- Sample program #3. Demonstrates problem when "RUN" is used in a program
- that contains soft key definitions. Compile with BC in QB 4.
- * Note: This problem has been fixed in BC 6.
-
- KEY 1, "Anything" + CHR$(13) ' Previous Quirks.Txt had "RUN"
- KEY 2, "END" + CHR$(13)
- PRINT "If you compiled with BC.EXE, RUN will crash your program"
- INPUT "(F1=RUN F2=END) ", yn$
- IF yn$ = "Anything" THEN RUN
- END
- ----------------------------------------------------------------------------
- Sample program #4. Demonstrates the limit on dynamic numeric
- arrays in QB 3. This program generates a program called
- ARRAY.BAS. Compile ARRAY.BAS with the "/d" switch, LINK it and
- RUN it. The sole function of ARRAY.BAS is to generate arrays.
- Regardless of the value of I%, and regardless if you use "#",
- "%" or "!" as the array type, the program gives an "Out of
- memory" error when the 124th array is DIMmed.
-
- OPEN "O",#1,"ARRAY.BAS"
- PRINT #1,"I%=1"
- FOR J=1 TO 126
- L=L+10:PRINT #1,MID$(STR$(L),2);" DIM A";MID$(STR$(J),2);"#(I%):PRINT FRE(-1)"
- NEXT
- CLOSE
- END
- ----------------------------------------------------------------------------
- Sample program #5. Demonstrates that the ERR variable does not get set
- when you "watch" a variable in a subprogram inside the QB 4 environment.
-
- Load this program into the QB 4 environment. Alt-V to view the sub
- "CheckFSpec". Alt-D <Enter> to watch any variable, then step through
- the program using F8. When you get to the ERRORHANDLER routine, watch
- ERR.
-
- DECLARE SUB CheckFSpec (FlName$)
- COMMON SHARED ErrCode%
- ErrCode% = 0
- a$ = "c:\quickey\data\tape2.000"
- CALL CheckFSpec(a$)
- CLOSE
- END
- ERRORHANDLER:
- IF ErrCode% = 0 OR ERR <> 0 THEN ErrCode% = ERR
- RESUME NEXT
- SUB CheckFSpec (FlName$) STATIC
- ON ERROR GOTO ERRORHANDLER
- OPEN FlName$ FOR INPUT AS #1
- ON ERROR GOTO 0
- IF ErrCode% = 0 THEN
- PRINT "Opened "; FlName$; " successfully."
- ELSE
- PRINT "Error"; ErrCode%; " attempting to open "; FlName$; "."
- END IF
- END SUB